package com.jwaoo.mobile.view.register.fragment;

import android.content.Context;
import android.view.View;
import android.widget.EditText;
import com.bigkoo.pickerview.OptionsPickerView;
import com.dx.as.common.FragmentUtils;
import com.dx.as.fragment.TFragment;
import com.jwaoo.mobile.R;
import com.jwaoo.mobile.bean.CommonData;
import com.jwaoo.mobile.view.register.IParamListener;
import java.util.List;

/**
 * Created by jwaoo on 2017/10/14.
 */

public class CountryFragment extends TFragment{
    private IParamListener listener;
    private EditText edt_country;
    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        listener = (IParamListener) context;
    }

    @Override
    public void initView() {
        findView(R.id.btn_next).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                FragmentUtils.goToFragment(getActivity(),NickNameFragment.class,R.id.register_container);
            }
        });
        findView(R.id.btn_back).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                FragmentUtils.goBackFragment(getActivity(),AccountFragment.class,R.id.register_container,CountryFragment.class);
            }
        });

        edt_country = findView(R.id.edt_country);
        edt_country.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onSeleced();
            }
        });
    }

    @Override
    public int setLayoutI() {
        return R.layout.fragment_country;
    }

    @Override
    public void dataOpion() {

    }

    @Override
    public void initRpo() {

    }

    @Override
    public void onResume() {
        super.onResume();
    }

    private void onSeleced(){
        final List<CommonData.CommonBean> list = CommonData.getCountryList();
        //条件选择器
        OptionsPickerView pvOptions = new  OptionsPickerView.Builder(getActivity(), new OptionsPickerView.OnOptionsSelectListener() {
            @Override
            public void onOptionsSelect(int options1, int option2, int options3 ,View v) {
                edt_country.setText(list.get(options1).getValue());
                listener.saveCuntry(list.get(options1).getKey());
            }
        }).build();
        pvOptions.setPicker(list);
        pvOptions.show();
    }
}
